package com.example.demo.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.example.demo.framework.base.BaseRepository;
import com.example.demo.model.Storage;

public interface StorageRepository extends JpaRepository<Storage, Long>, JpaSpecificationExecutor<Storage>,BaseRepository<Storage, Long> {

	
	@Query("from Storage c where c.status=?1")
	public List<Storage> findByStatus(Integer status);
	
	@Query("from Storage c where c.sID=?1 and c.status=1")
	public Storage getByID(Long sID);
	
	@Modifying
	@Query("update Storage s set s.pStorageName=?1,s.pStorageCode=?2 where s.parentID=?3")
	public int updatePStorageNameAndPCodeByParentID(String pStorageName,String pStorageCode,long parentID);
	
	@Modifying
	@Query("update Storage s set s.status=0 where s.parentID=?1")
	public int updateStatusByParentID(long parentID);

}
